package cn.com.customer.manager.ui.message.msg

import cn.com.customer.manager.bean.MessageListInfo
import cn.com.customer.manager.bean.MsgListInfo
import cn.com.customer.manager.bean.RequestBean
import cn.com.customer.manager.http.BaseApi
import cn.com.customer.manager.http.subscriber.TipRequestSubscriber
import com.xuexiang.xhttp2.XHttp
import com.xuexiang.xhttp2.XHttpProxy
import com.xuexiang.xhttp2.annotation.ThreadType
import com.xuexiang.xhttp2.model.ApiResult

class MessagePresenter constructor(view:MessageContract.View):MessageContract.Presenter {
    var mView:MessageContract.View=view
    init {
        mView.setPresenter(this)
    }
    override fun getMessages(params: Map<String, String>) {

        val request = XHttp.custom()
        request.call(request.create(BaseApi.IMessage::class.java)
                .smsList(RequestBean(params)))
                .subscribeWith(object : TipRequestSubscriber<ApiResult<MsgListInfo>?>() {
                    override fun onSuccess(apiResult: ApiResult<MsgListInfo>?) {
                        apiResult?.let {
                            if (it.data!=null){
                                mView.setMessages(it.data)
                            }
                        }
                    }
                })
    }

    override fun start() {

    }
}